package com.example.badminton.controller;

import com.example.badminton.common.Result;
import com.example.badminton.common.AnonymousAccess;
import com.example.badminton.entity.Banner;
import com.example.badminton.service.BannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/banner")
@CrossOrigin
public class BannerController {
    
    @Autowired
    private BannerService bannerService;
    
    /**
     * 获取轮播图列表
     */
    @AnonymousAccess
    @GetMapping("/list")
    public Result<?> getBannerList() {
        try {
            List<Banner> bannerList = bannerService.getActiveBanners();
            return Result.success(bannerList);
        } catch (Exception e) {
            return Result.error("获取轮播图失败: " + e.getMessage());
        }
    }
} 